<template>
  <div>{{ year }}</div>
</template>

<script>
import { defineComponent, ref, watch } from 'vue'
export default defineComponent({
  setup() {
    const year = ref(0)

    setTimeout(() => {
      year.value++
    }, 1000)

    watch(year, (newVal, oldVal) => {
      console.log('新值:', newVal, '老值:', oldVal)
      //新值: 1 老值: 0
    })

    return { year }
  }
})
</script>

<style>
</style>